home *** CD-ROM | disk | FTP | other *** search
/ The CDPD Public Domain Collection for CDTV 4 / CDPD_IV.bin / e / mailinglists / amigae.0294feb.archive / 000094_donews!crash!fr…leton.ca!ao443_Thu, 24 Feb 94 01:11:57 PST.msg < prev    next >
Internet Message Format  |  1994-05-26  |  5KB

  1. Received: by bkhouse.cts.com (V1.17-beta/Amiga)
  2.       id <1wgy@bkhouse.cts.com>; Thu, 24 Feb 94 01:11:57 PST
  3. Received: from crash by donews.cts.com with uucp
  4.     (Smail3.1.28.1 #18) id m0pZNSy-0001TUC; Wed, 23 Feb 94 12:33 EST
  5. Received: from freenet-news.carleton.ca by crash.cts.com with smtp
  6.     (Smail3.1.28.1 #18) id m0pZN8Z-0000V9C; Wed, 23 Feb 94 09:12 PST
  7. Received: from freenet.carleton.ca by freenet-news.carleton.ca (4.1/SMI-4.0)
  8.     id AA06775; Wed, 23 Feb 94 12:13:04 EST
  9. Received: from localhost (ao443@localhost) by freenet.carleton.ca (8.6.4/8.6.4) id MAA09588; Wed, 23 Feb 1994 12:12:26 -0500
  10. Date: Wed, 23 Feb 1994 12:12:26 -0500
  11. Message-Id: <199402231712.MAA09588@freenet.carleton.ca>
  12. Reply-To: ao443@freenet.carleton.ca
  13. From: ao443@freenet.carleton.ca (Jason Maskell)
  14. To: amigae@bkhouse.cts.com
  15. Subject: Problem IFFParse code.
  16.  
  17.     Well, here is the program that I told you people about. Take it
  18. home, nurture it, see if you can get it to straighten up and fly right. If
  19. it works when you compile it (as it should), then something is wrong with
  20. my iffparse library.
  21.  
  22. /*
  23.     ILBM brush to Image.
  24. */
  25. MODULE 'dos/dos','intuition/intuition','asl','libraries/asl',
  26. 'libraries/iffparse','iffparse','utility/tagitem'
  27. ENUM NOERROR,ER_LIBRARY,ER_NOMEM,ER_NOASLREQUEST,ER_FILENOTFOUND,ER_IFFERROR,
  28.     ER_NOBMHD
  29. CONST ID_ILBM=$494C424D
  30. CONST ID_BMHD=$424D4844
  31. CONST ID_BODY=$424F4459
  32. CONST ID_CMAP=$434D4150
  33.  
  34. DEF iff:PTR TO iffhandle
  35.  
  36. PROC main()
  37.     DEF req:PTR TO filerequestr,source[256]:STRING,err,xsize,ysize,depth,bmhd,
  38.     body,cmap,camg,cflag,p:PTR TO INT,bp:PTR TO CHAR,sp:PTR TO storedproperty
  39.  
  40.     IF KickVersion(37)=FALSE
  41.         WriteF('Sorry, Kickstart V37+ Required.\n')
  42.         getout(0)
  43.     ENDIF
  44.     IF (aslbase:=OpenLibrary('asl.library',37))=0
  45.         error(ER_LIBRARY,'asl')
  46.     ENDIF
  47.     IF (iffparsebase:=OpenLibrary('iffparse.library',37))=0
  48.         error(ER_LIBRARY,'iffparse')
  49.     ENDIF
  50.     IF (req:=AllocAslRequest(ASL_FILEREQUEST,[ASL_HAIL,'Choose ILBM to
  51. convert',0]:tagitem))>0
  52.         IF AslRequest(req,0)=0
  53.             FreeAslRequest(req)
  54.             getout(0)
  55.         ELSE
  56.             StrCopy(source,req.dir,ALL) ;
  57. AddPart(source,req.file,256) ; SetStr(source,StrLen(source))
  58.         ENDIF
  59.     ELSE
  60.         error(ER_NOASLREQUEST,0)
  61.     ENDIF
  62.     IF FileLength(source)>0
  63.         IF (iff:=AllocIFF())>0
  64.             iff.stream:=Open(source,MODE_OLDFILE)
  65.             InitIFFasDOS(iff)
  66.             IF (err:=OpenIFF(iff,IFFF_READ))=0
  67.                 IF (err:=PropChunk(iff,"ILBM","BMHD"))=0
  68.                     IF (err:=ParseIFF(iff,IFFPARSE_SCAN)=IFFERR_EOF)
  69.                         IF (sp:=FindProp(iff,"ILBM","BMHD"))>0
  70.                             bmhd:=sp.data
  71.                             bp:=p:=bmhd ;
  72. xsize:=p[2] ; ysize:=p[3]
  73.                             depth:=bp[13] ; cflag:=bp[14]
  74.                         ELSE
  75.                             error(ER_NOBMHD,0)
  76.                         ENDIF
  77.                         WriteF('Start:\z\h[8]
  78. Xsize:\d Ysize:\d Compression:\d Depth:\d\n',bmhd,xsize,ysize,cflag,depth)
  79.                         getout(0)
  80.                     ELSE
  81.                         error(ER_IFFERROR,err)
  82.                     ENDIF
  83.                 ELSE
  84.                     error(ER_IFFERROR,err)
  85.                 ENDIF
  86.             ELSE
  87.                 error(ER_IFFERROR,err)
  88.             ENDIF
  89.         ELSE
  90.             error(ER_IFFERROR,IFFERR_NOMEM)
  91.         ENDIF
  92.     ELSE
  93.         error(ER_FILENOTFOUND,source)
  94.     ENDIF
  95. ENDPROC
  96. CHAR '$VER: ILBM2Image v.01 (C) 1994 Jason Maskell',0
  97.  
  98. PROC getout(retcode)
  99.     IF iff
  100.         CloseIFF(iff)
  101.         Close(iff.stream)
  102.         FreeIFF(iff)
  103.     ENDIF
  104.     IF aslbase
  105.         CloseLibrary(aslbase)
  106.     ENDIF
  107.     IF iffparsebase
  108.         CloseLibrary(iffparsebase)
  109.     ENDIF
  110.     CleanUp(retcode)
  111. ENDPROC
  112.  
  113. PROC error(errnum,str)
  114.     DEF work[80]:STRING
  115.     SELECT errnum
  116.         CASE ER_LIBRARY
  117.             StringF(work,'Could not open \s.library V37+',str)
  118.         CASE ER_NOMEM
  119.             StringF(work,'Unable to allocate memory.')
  120.         CASE ER_NOASLREQUEST
  121.             StringF(work,'Unable to allocate ASL requester.')
  122.         CASE ER_FILENOTFOUND
  123.             StringF(work,'File "\s" not found.',str)
  124.         CASE ER_IFFERROR
  125.             SELECT str
  126.                 CASE IFFERR_EOC
  127.                     StringF(work,'Iffparse Error: End
  128. of Context')
  129.                 CASE IFFERR_NOSCOPE
  130.                     StringF(work,'Iffparse Error: No
  131. valid scope')
  132.                 CASE IFFERR_NOMEM
  133.                     StringF(work,'Iffparse Error:
  134. Internal Memory allocation failed.')
  135.                 CASE IFFERR_READ
  136.                     StringF(work,'Iffparse Error:
  137. Stream Read Error.')
  138.                 CASE IFFERR_WRITE
  139.                     StringF(work,'Iffparse Error:
  140. Stream Write Error.')
  141.                 CASE IFFERR_SEEK
  142.                     StringF(work,'Iffparse Error:
  143. Stream Seek Error.')
  144.                 CASE IFFERR_MANGLED
  145.                     StringF(work,'Iffparse Error: IFF
  146. file is corrupt.')
  147.                 CASE IFFERR_SYNTAX
  148.                     StringF(work,'Iffparse Error: IFF
  149. Syntax Error.')
  150.                 CASE IFFERR_NOTIFF
  151.                     StringF(work,'Iffparse Error: Not
  152. an IFF file.')
  153.                 DEFAULT
  154.                     StringF(work,'Iffparse Error:
  155. Unknown Error code: \d',str)
  156.             ENDSELECT
  157.         CASE ER_NOBMHD
  158.             StringF(work,'No Bitmapheader found. Not a usable FORM')
  159.         DEFAULT
  160.             StringF(work,'Unknown Error code: \d',errnum)
  161.     ENDSELECT
  162.     request('ILBN2Image Error',work,'Ok',0)
  163.     getout(11)
  164. ENDPROC
  165. PROC request(title,body,gadgets,args)
  166. ENDPROC EasyRequestArgs(0,[20,0,title,body,gadgets],0,args)
  167.  
  168.  
  169. --
  170. 'You see son, if this were Star Trek, we'd be negotiating with this Kobold.'
  171. - Unknown Angband Player